{include file="public/nheader" /}
<style type="text/css">
    #container {
        min-width: 100px;
        min-height: 300px;
    }
</style>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=2AEBZ-YK23W-XISR6-ROOGV-VOLI7-46FFT"></script>
<div class="layui-fluid layui-bg-white">
    <form action="{:url()}" class="layui-form layui-form-fixed">
        <div class="layui-form-item">
            <label class="layui-form-label"> 备注
            </label>
            <div class="layui-input-block">
                <input type="text" disabled required="" lay-verify="required" autocomplete="off" class="layui-input"
                    value="{$row.nickname|default=''}" placeholder="请填写代理备注">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"> 商家账号
            </label>
            <div class="layui-input-block">
                <input type="text" disabled required="" lay-verify="required" autocomplete="new-password"
                    class="layui-input" value="{$row.accounts|default=''}" placeholder="请填写商家账号">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"> 账户余额
            </label>
            <div class="layui-input-block">
                <input type="text" disabled required="" lay-verify="required" autocomplete="new-password"
                    class="layui-input" value="{$row.money|default='0'}" placeholder="">
            </div>
        </div>

        <!-- <div class="layui-form-item">
            <label class="layui-form-label">兑换卡需缴纳金额(请联系平台)
            </label>
            <div class="layui-input-block">
                <input type="text" disabled required="" lay-verify="required" autocomplete="new-password"
                    class="layui-input" value="{$row.money2|default='0'}" placeholder="">
            </div>
        </div> -->
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>N元洗鞋活动
            </label>
            <div class="layui-input-block">
                <input type="radio" name="yyopen" value="1" title="关闭" {if !empty($row.yyopen) &&
                    $row.yyopen==1}checked{/if}>
                <input type="radio" name="yyopen" value="2" title="开启" {if empty($row.yyopen) ||
                    $row.yyopen==2}checked{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>49.8洗鞋活动
            </label>
            <div class="layui-input-block">
                <input type="radio" name="youhui" value="1" title="开启" {if !empty($row.youhui) &&
                    $row.youhui==1}checked{/if}>
                <input type="radio" name="youhui" value="2" title="关闭" {if empty($row.youhui) ||
                    $row.youhui==2}checked{/if}>
                <div>(该活动为全国活动，关闭活动仅限制关闭在服务区域购买功能，不限制已购买服务使用功能)</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>线下支付(关闭后用户不可线下支付)
            </label>
            <div class="layui-input-block">
                <input type="radio" name="payopen" value="1" title="关闭" {if !empty($row.payopen) &&
                    $row.payopen==1}checked{/if}>
                <input type="radio" name="payopen" value="2" title="开启" {if empty($row.payopen) ||
                    $row.payopen==2}checked{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>享会员服务开关(开启后下单用户享会员价)
            </label>
            <div class="layui-input-block">
                <input type="radio" name="levelopen" value="1" title="关闭" {if !empty($row.levelopen) &&
                    $row.levelopen==1}checked{/if}>
                <input type="radio" name="levelopen" value="2" title="开启" {if empty($row.levelopen) ||
                    $row.levelopen==2}checked{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>会员折扣率(范围1-100,90表示9折，87表示8.7折)
            </label>
            <div class="layui-input-block">
                <input type="number" name="levelrate" required="" lay-verify="required" autocomplete="off"
                    class="layui-input" value="{$row.levelrate|default='100'}" placeholder="请填写会员折扣率">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>联系电话(提现手机,如需更改请联系管理员)
            </label>
            <div class="layui-input-block">
                <input type="number" disabled name="mobile" required="" lay-verify="required" autocomplete="off"
                    class="layui-input" value="{$row.mobile|default=''}" placeholder="请填写联系电话">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                登录密码
            </label>
            <div class="layui-input-block">
                <input type="password" name="password" autocomplete='new-password' class="layui-input"
                    placeholder="请登录密码">

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>门店地址(请精确到门面位置)
            </label>
            <div class="layui-input-block">
                <input type="text" name="address" required="" lay-verify="required" autocomplete="off"
                    class="layui-input" value="{$row.address|default=''}" placeholder="请填写门店地址">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                门店坐标
            </label>
            <div class="layui-input-block">
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <input type="text" id="posaddress" name="posaddress" autocomplete="on" class="layui-input"
                            value="" placeholder="搜索地址">
                        <div id="sousuo" style="min-height:20px;max-height:150px;overflow-y:scroll">
                        </div>
                    </div>
                    <div class="layui-col-xs12">
                        <div id="container"></div>
                    </div>
                </div>

            </div>
        </div>
        <div class="layui-footer layui-form-item layui-center ">
            <input type="hidden" value="{$row['id']|default='0'}" name="id" />
            <input type="hidden" value="{$row.lat|default='39.90880615'}" name="lat">
            <input type="hidden" value="{$row.lon|default='116.39746431'}" name="lon">
            <button class="layui-btn" lay-filter="submitIframe" type="button" lay-submit>提交</button>
            <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
        </div>
    </form>
</div>
{include file="public/nfooter" /}
<script>
    layui.use(['layer', 'jquery', 'form', 'laydate'], function () {
        $ = layui.jquery;
        var form = layui.form
            , laydate = layui.laydate
            , layer = layui.layer;
        //腾讯地图部分
        var position = document.getElementById("position");
        var center = new qq.maps.LatLng("{$row.lat|default='39.90880615'}", "{$row.lon|default='116.39746431'}");//设置中心点坐标
        //初始化地图
        var map = new qq.maps.Map("container", {
            center: center,
            zoom: 17,
            viewmode: '3D',
            pitch: 50
        });
        //初始化infoWindow
        var infoWindow = new qq.maps.InfoWindow({
            map: map
        });
        infoWindow.open();
        infoWindow.setContent("门店位置");
        infoWindow.setPosition(map.getCenter());
        //点击事件
        qq.maps.event.addListener(map, 'click', function (evt) {
            var lat = evt.latLng.getLat().toFixed(8);
            var lng = evt.latLng.getLng().toFixed(8);
            var center = new qq.maps.LatLng(lat, lng);//设置中心点坐标
            infoWindow.setPosition(center);
            $("input[name='lat']").val(lat);
            $("input[name='lon']").val(lng);
        });
        //输入框的值改变时触发
        $("#posaddress").on("input", function (e) {
            var title = e.delegateTarget.value;
            $.ajax({
                type: 'get',
                url: '/base/getaddress',
                data: { keyword: title },
                success: function (res) {
                    if (res.code == 0) {
                        str = '';
                        $.each(res.data, function (i, obj) {
                            if (i < 5) {
                                str += '<input lay-filter="getsou" type="radio" name="suosuo" value="' + obj.location.lat + ',' + obj.location.lng + '" title="' + obj.title + '[' + obj.address + ']' + '"><br/>';
                            }
                        });
                        $('#sousuo').html(str);
                        form.render();
                    }
                }
            });
            return false;
        });
        //搜索监听
        form.on('radio(getsou)', function (data) {
            var location = data.value.split(","); //字符分割 
            var center = new qq.maps.LatLng(location[0], location[1]);//设置中心点坐标
            map.setCenter(center);
            infoWindow.setPosition(center);
            $("input[name='lat']").val(location[0]);
            $("input[name='lon']").val(location[1]);
        });
    });
</script>